<?php

/**
 * 
 * @project     : innoTweets 1.0
 * @author      : Dino (DBK)
 * 
 * @package     : Gallery (Albums)
 * @description : Shows the list of albums
 * 
 */
if (!defined('BASEPATH')) {
  exit('No direct script access allowed');
}

class Albums extends AUTH_Controller {

  /**
   * Albums list
   * 
   */
  public function index($type = NULL) {

    // Getting limit count
    $limit = $this->input->get('limit', TRUE);
    $limit = (is_numeric($limit)) ? $limit : 12;

    // Getting album type
    if ($type == 'my') {
      $get_albums = $this->album_model->get_albums($this->current_user['user_id'], $limit);
      $get_albums_count = $this->album_model->get_albums_count($this->current_user['user_id'], $limit);
      $photos_count_data = $this->album_model->get_album_items_count(NULL, $this->current_user['user_id'], 1);
      $videos_count_data = $this->album_model->get_album_items_count(NULL, $this->current_user['user_id'], 2);
    } else {
      $get_albums = $this->album_model->get_albums(NULL, $limit);
      $get_albums_count = $this->album_model->get_albums_count(NULL, $limit);
      $photos_count_data = $this->album_model->get_album_items_count(NULL, NULL, 1);
      $videos_count_data = $this->album_model->get_album_items_count(NULL, NULL, 2);
    }

    // Preparing and loading view
    $view_data = array();
    $view_data['menu_active'] = 'albums';
    $view_data['type'] = $type;
    $view_data['limit'] = $limit;
    $view_data['albums_data'] = $get_albums['result'];
    $view_data['albums_count'] = (int) $get_albums_count['result'];
    $view_data['total_photos'] = (int) $photos_count_data['result'];
    $view_data['total_videos'] = (int) $videos_count_data['result'];

    // Loading view
    $this->load_view('albums', $view_data);
  }

}

?>